package pnt.message;

import java.net.InetSocketAddress;

import pnt.message.objects.User;


public class Request_ConnectOut extends Request {
	
	String applicationname;
	User target;
	User from;
	InetSocketAddress fromendpoint;
	InetSocketAddress toendpoint;
	InetSocketAddress predictfromendpoint;

	public Request_ConnectOut(	int transactionnumber, 
								User target, 
								RequestType requesttype, 
								String applicationname,
								User from,
								InetSocketAddress fromendpoint,
								InetSocketAddress toendpoint,
								InetSocketAddress predictfromendpoint) {
		super(transactionnumber, requesttype);
		this.applicationname = applicationname;
		this.target = target;
		this.from = from;
		this.fromendpoint = fromendpoint;
		this.toendpoint = toendpoint;
		this.predictfromendpoint = predictfromendpoint;
	}

	@Override
	public byte[] toBytes() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public String getRequestParameters(){
		return (target == null ? "*" : target.toString());
	}

	@Override
	public String toString(String end, String term) {
		// TODO Auto-generated method stub
		return 			
			"CONNECT-OUT " + getRequestParameters() + " PNT/1.0" + end +
			"Transaction: " + super.getTransactionNumber() + end +
			"Application: " + applicationname + end +
			"From: " + from + end +
			"From-Endpoint: " + Utils.formatSocketAddress(fromendpoint) + end +
			"To-Endpoint: " + Utils.formatSocketAddress(toendpoint) + end + 
			"Predict-From-Endpoint: " + Utils.formatSocketAddress(predictfromendpoint) + term;
	}

}
